Conversation
|
✔️ Deploy Preview for stackbit-components ready! 🔨 Explore the source changes: 84cd131 🔍 Inspect the deploy log: https://app.netlify.com/sites/stackbit-components/deploys/6109d0a779b42200079dfb8f 😎 Browse the preview: https://deploy-preview-1--stackbit-components.netlify.app |
|
@TomasBankauskas good start! The hero section have 4 variants, but they all look the same. For example the For example, to have a hero section with image or video, you can have a field The hero section has both Consider renaming |
There was a problem hiding this comment.
@TomasBankauskas good work! 👍
I've commented here on some thing that we need to improve, but you can already merge it.
| case 'variant-e': | ||
| return HeroNoFeature(props); |
There was a problem hiding this comment.
@TomasBankauskas I think there is no need in variant-e. Because in any variant if the feature object is not set, then it will be the same as HeroNoFeature.
You can check here if the feature is not set, then you can render HeroNoFeature and remove variant-e fomt he model
| if (!feature) { | ||
| return null; | ||
| } |
There was a problem hiding this comment.
@TomasBankauskas returning null here is too late. Because you will get an empty div:
<div className="mt-8 lg:mt-12">
</div>| 'max-w-screen-xl': width === 'wide', | ||
| 'max-w-screen-lg': width === 'narrow', | ||
| 'min-h-screen flex flex-col justify-center': height === 'viewport', | ||
| 'text-center': alignHoriz === 'center' |
There was a problem hiding this comment.
Will it be ok if we add alignment "right"?
| {props.badge && <Badge label={props.badge} />} | ||
| {props.title && ( | ||
| <h1 className="font-medium font-sans text-4xl tracking-tight sm:text-5xl mb-6"> | ||
| <ReactMarkdown allowedElements={['br', 'span', 'strong']} unwrapDisallowed={true} components={components}> |
There was a problem hiding this comment.
The allowedElements might be too limited, what about italics (*italics*) or links ([link](https://...))?
Let's use markdown-to-jsx. There is also an option forceInline which will ensure that it will not try to wrap it with block elements like <p> or <h1>
There was a problem hiding this comment.
P.S.:
This can wait for next iteration
| 'mx-auto': width !== 'full', | ||
| 'max-w-screen-xl': width === 'wide', | ||
| 'max-w-screen-lg': width === 'narrow', |
There was a problem hiding this comment.
@TomasBankauskas this code snippet is used in 6 places.
Is it possible to make it a utility function, or even better, remap it to a new utility style like section-w-full, section-w-wide, section-w-narrow?
To make it easier for developers to update style via tailwind.config.js rather cloning and customizing all components.
| 'mx-auto': width !== 'full', | ||
| 'max-w-screen-xl': width === 'wide', | ||
| 'max-w-screen-lg': width === 'narrow', | ||
| 'min-h-screen flex flex-col justify-center': height === 'viewport', |
There was a problem hiding this comment.
Same for this one, can we create a utility class section-h-viewport? This way developers will be able to customize all section heights without customizing all sections.
| <div | ||
| className="w-full lg:inset-y-0 lg:w-1/2 lg:max-w-full lg:absolute right-0 lg:pl-4"> | ||
| <img | ||
| src={props.imageUrl} | ||
| className="w-screen max-w-none ml-1/2 transform -translate-x-1/2 object-cover lg:h-full lg:ml-0 lg:transform-none lg:w-full lg:max-w-full" | ||
| alt={props.imageAltText} | ||
| /> | ||
| </div> |
There was a problem hiding this comment.
Consider using ImageBlock here. Even if it is the only possible type for this section.
| switch (feature.type) { | ||
| case 'image_block': | ||
| return <ImageBlock {...feature} className={classNames({ 'mx-auto': alignHoriz === 'center' })} />; | ||
| case 'video_block': | ||
| return <VideoBlock {...feature} />; | ||
| } |
There was a problem hiding this comment.
Unlike the variants which are constant, types that can be embedded into Hero section are dynamic.
fields:
- type: model
name: feature
label: Feature
categories: [hero_block]
That means that feature field can container any model, not only image_block or video_block.
Therefore, the code should be similar to how it works in Advanced layout:
const Component = components[sectionType];
return <Component {...feature} />;
Note: the models YAML don't support categories yet.
| export default function Button({ label, url, icon, alt, className }) { | ||
| const iconMap = { | ||
| arrowRight: ArrowRight, | ||
| cart: Cart | ||
| }; |
There was a problem hiding this comment.
Don't we support button primary anymore?
How would user be able to change button from primary to secondary without changing the style of the whole section?
| switch (field.inputType) { | ||
| case 'checkbox': | ||
| return ( |
There was a problem hiding this comment.
Here, the form controls should be separates into separate components, each with their own type.
And the form would have a list of fields models categorized as "form-field".
Then developer will be able to create new types of "form-fields":
const Component = components[field.type];
return <Component {...field} />;
| '.colors-a': { | ||
| backgroundColor: theme('colors.base-50'), | ||
| color: theme('colors.base-900'), | ||
| 'input,textarea,select,hr': { | ||
| borderColor: theme('colors.base-900') | ||
| }, | ||
| '::placeholder': { | ||
| color: theme('colors.base-900') | ||
| }, | ||
| '.sb-btn': { | ||
| backgroundColor: theme('colors.primary'), | ||
| color: theme('colors.base-900'), | ||
| '&:hover': { | ||
| backgroundColor: theme('colors.primary-variant') | ||
| }, | ||
| }, | ||
| '.sb-card': { | ||
| backgroundColor: theme('colors.secondary') | ||
| } | ||
| }, |
There was a problem hiding this comment.
@TomasBankauskas is there a way to define flat object with colors and apply them to components like in DaisyUI?
In DaisyUI, they use it for themes, so each theme has a flat object with different set of colors that is applied everywhere else.
https://github.com/saadeghi/daisyui/blob/master/src/colors/themes.js#L2-L23
Then buttons assigned base text colors and background colors:
https://github.com/saadeghi/daisyui/blob/master/src/components/styled/button.css#L26-L56
- added dynamic/imports - moved models to root folder
Task:
https://www.notion.so/stackbit/Implement-2-themes-and-5-6-components-87c240fb9bb141689530219e6d86673b